//
//  PeopleOneView.m
//  AILove
//
//  Created by 甘世清 on 2024/1/8.
//

#import "PeopleOneView.h"

@implementation PeopleOneView

- (void)SQ_UIViewForSelfView{
    self.backgroundColor = SQHexColor(@"#000000", 0.7);
    [self addSubview:self.oneView];
    [self addSubview:self.towView];
    [self.oneView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(self);
    }];
    [self.towView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(self);
    }];
    
    UIPanGestureRecognizer *pan = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(panGestureHandle:)];
    [self.oneView addGestureRecognizer:pan];
    
    UIPanGestureRecognizer *tap = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(tapGestureHandle:)];
    [self.towView addGestureRecognizer:tap];
    
    [self.oneView addSubview:self.leftButton];
    [self.leftButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self);
        make.size.mas_equalTo(80);
        make.top.equalTo(self).offset(SCREEN_HEIGHT-FootHeight-280);
    }];
    
    UIImageView * oneImage = [[UIImageView alloc]init];
    oneImage.image = SQGetImage(@"1");
    oneImage.contentMode = UIViewContentModeScaleAspectFit;
    [self.oneView addSubview:oneImage];
    [oneImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.mas_equalTo(120);
        make.height.mas_equalTo(60);
        make.left.equalTo(self.leftButton.mas_right);
        make.centerY.equalTo(self.leftButton);
    }];
    UILabel * l1 = [[UILabel alloc]init];
    l1.text = SQNSLocalString(@"左滑不喜欢");
    l1.font = FONT_MEDIUM(20);
    l1.textColor = UIColor.whiteColor;
    [self.oneView addSubview:l1];
    [l1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(oneImage);
        make.left.equalTo(oneImage.mas_right);
    }];
    
    [self.towView addSubview:self.loveButton];
    [self.loveButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.mas_right);
        make.size.mas_equalTo(80);
        make.top.equalTo(self).offset(SCREEN_HEIGHT-FootHeight-280);
    }];
    UIImageView * towImage = [[UIImageView alloc]init];
    towImage.image = SQGetImage(@"2");
    towImage.contentMode = UIViewContentModeScaleAspectFit;
    [self.towView addSubview:towImage];
    [towImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.mas_equalTo(120);
        make.height.mas_equalTo(60);
        make.right.equalTo(self.loveButton.mas_left);
        make.centerY.equalTo(self.loveButton);
    }];
    
    UILabel * l12 = [[UILabel alloc]init];
    l12.text = SQNSLocalString(@"右滑喜欢,查看详情");
    l12.font = FONT_MEDIUM(20);
    l12.textColor = UIColor.whiteColor;
    [self.towView addSubview:l12];
    [l12 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(towImage.mas_top);
        make.right.equalTo(towImage.mas_left).offset(52);
    }];
}
- (void)panGestureHandle:(UIPanGestureRecognizer *)gesture {
    
        self.oneView.hidden = YES;
        self.towView.hidden = NO;
   
}

- (void)tapGestureHandle:(UITapGestureRecognizer *)tap {
   
        [Manager SQ_SetObject:@"111" FormKey:@"oneView"];
        self.dismissBlock();
     
}
 
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
    if (self.oneView.hidden) {
        [Manager SQ_SetObject:@"111" FormKey:@"oneView"];
        self.dismissBlock();
    } else {
        self.oneView.hidden = YES;
        self.towView.hidden = NO;
    }
}
- (UIView *)oneView{
    if (!_oneView) {
        _oneView = [[UIView alloc]init];
        _oneView.backgroundColor = UIColor.clearColor;
        _oneView.userInteractionEnabled = YES;
    }
    return _oneView;
}
- (UIView *)towView{
    if (!_towView) {
        _towView = [[UIView alloc]init];
        _towView.backgroundColor = UIColor.clearColor;
        _towView.hidden = YES;
        _towView.userInteractionEnabled = YES;
    }
    return _towView;
}

- (SQCustomButton *)leftButton{
    if (!_leftButton) {
        _leftButton = [[SQCustomButton alloc]initType:SQCustomButtonTopImageType imageSize:CGSizeMake(50, 50) midmargin:0];
        _leftButton.image = SQGetImage(@"不喜欢");
        _leftButton.userInteractionEnabled = NO;
    }
    return _leftButton;
}
- (SQCustomButton *)loveButton{
    if (!_loveButton) {
        _loveButton = [[SQCustomButton alloc]initType:SQCustomButtonTopImageType imageSize:CGSizeMake(50, 50) midmargin:0];
        _loveButton.image = SQGetImage(@"喜欢");
        _loveButton.userInteractionEnabled = NO;
    }
    return _loveButton;
}
@end
